﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KCMS.BusinessLogic.Interfaces;
using KCMS.BusinessLogic.Models;
using StructureMap;
using AutoMapper;
using KCMS.Web.Models;

namespace KCMS.Controllers
{
    public class PageController : Controller
    {
        //
        // GET: /Page/
        private IPageService pService = ObjectFactory.GetInstance<IPageService>();
        public ActionResult Index()
        {
            Guid id = new Guid();
            BusinessLogic.Models.Page page = pService.getById(id);
            var model = Mapper.Map<BusinessLogic.Models.Page, KCMS.Web.Models.PageViewModel>(page);
            return View(model);
        }
       public ActionResult ShowWithCategory(String code,String category)
        {

            BusinessLogic.Models.Page page = pService.getByCode(code);
            var model = Mapper.Map<BusinessLogic.Models.Page, KCMS.Web.Models.PageViewModel>(page);
            return View("Show",model);
        }
       public ActionResult Show(String code)
       {
           BusinessLogic.Models.Page page = pService.getByCode(code);
           var model = Mapper.Map<BusinessLogic.Models.Page, KCMS.Web.Models.PageViewModel>(page);
           return View(model);
       }
       //public ActionResult Show(String code, int index)
       //{

       //    BusinessLogic.Models.Page page = productService.getByCodeIndex(code, index);
       //    var productImage = Mapper.Map<BusinessLogic.Models.Page, KCMS.Web.Models.PageViewModel>(page);
       //    return View(productImage);
       //}
        public ActionResult FrontPage()
        {
            BusinessLogic.Models.Page page = pService.getByCodeIndex("главная", 0);
            var model = Mapper.Map<BusinessLogic.Models.Page, KCMS.Web.Models.PageViewModel>(page);
            return PartialView("Show",model);
        }

    }
}
